package tech.summerly.weather.data.local

import android.support.test.runner.AndroidJUnit4
import org.junit.Assert
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import tech.summerly.weather.util.Position

@RunWith(AndroidJUnit4::class)
class RegionJsonReaderTest {


    private val china = RegionJsonReader.JsonCity("中华人民共和国", Position(132.0, 23.0), RegionJsonReader.JsonCity.LEVEL_COUNTRY, ArrayList())
    private val hunan = RegionJsonReader.JsonCity("湖南省", Position(132.0, 23.0), RegionJsonReader.JsonCity.LEVEL_PROVINCE, ArrayList())
    private val shaoyang = RegionJsonReader.JsonCity("邵阳市", Position(132.0, 23.0), RegionJsonReader.JsonCity.LEVEL_CITY, ArrayList())
    private val wugang = RegionJsonReader.JsonCity("武冈市", Position(132.0, 23.0), RegionJsonReader.JsonCity.LEVEL_DISTRICT, ArrayList())

    @Before
    fun init() {
        china.districts.add(hunan)
        hunan.districts.add(shaoyang)
        shaoyang.districts.add(wugang)
        china.initParentNode()
    }

    @Test
    fun getFullString() {
        Assert.assertEquals("湖南省,邵阳市,武冈市", wugang.getFullString())
        Assert.assertEquals("湖南省,邵阳市", wugang.parent!!.getFullString())
        Assert.assertEquals("湖南省", wugang.parent!!.parent!!.getFullString())
    }

}